.class public Lcom/zuiapps/suite/utils/network/NetWorkHelper;
.super Ljava/lang/Object;
.source "NetWorkHelper.java"


# static fields
.field private static LOG_TAG:Ljava/lang/String;

.field public static uri:Landroid/net/Uri;


# direct methods
.method static constructor <clinit>()V
    .registers 1

    .prologue
    .line 15
    const-string v0, "NetWorkHelper"

    sput-object v0, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->LOG_TAG:Ljava/lang/String;

    .line 17
    const-string v0, "content://telephony/carriers"

    invoke-static {v0}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v0

    sput-object v0, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->uri:Landroid/net/Uri;

    return-void
.end method

.method public constructor <init>()V
    .registers 1

    .prologue
    .line 13
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static isMobileDataEnable(Landroid/content/Context;)Z
    .registers 4
    .param p0, "context"    # Landroid/content/Context;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 74
    const-string v2, "connectivity"

    invoke-virtual {p0, v2}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/net/ConnectivityManager;

    .line 75
    .local v0, "connectivityManager":Landroid/net/ConnectivityManager;
    const/4 v1, 0x0

    .line 77
    .local v1, "isMobileDataEnable":Z
    const/4 v2, 0x0

    invoke-virtual {v0, v2}, Landroid/net/ConnectivityManager;->getNetworkInfo(I)Landroid/net/NetworkInfo;

    move-result-object v2

    invoke-virtual {v2}, Landroid/net/NetworkInfo;->isConnectedOrConnecting()Z

    move-result v1

    .line 79
    return v1
.end method

.method public static isNetworkAvailable(Landroid/content/Context;)Z
    .registers 6
    .param p0, "context"    # Landroid/content/Context;

    .prologue
    .line 23
    const-string v3, "connectivity"

    invoke-virtual {p0, v3}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/net/ConnectivityManager;

    .line 25
    .local v0, "connectivity":Landroid/net/ConnectivityManager;
    if-nez v0, :cond_1a

    .line 26
    sget-object v3, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->LOG_TAG:Ljava/lang/String;

    const-string v4, "couldn\'t get connectivity manager"

    invoke-static {v3, v4}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 38
    :cond_11
    sget-object v3, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->LOG_TAG:Ljava/lang/String;

    const-string v4, "network is not available"

    invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 39
    const/4 v3, 0x0

    :goto_19
    return v3

    .line 28
    :cond_1a
    invoke-virtual {v0}, Landroid/net/ConnectivityManager;->getAllNetworkInfo()[Landroid/net/NetworkInfo;

    move-result-object v2

    .line 29
    .local v2, "info":[Landroid/net/NetworkInfo;
    if-eqz v2, :cond_11

    .line 30
    const/4 v1, 0x0

    .local v1, "i":I
    :goto_21
    array-length v3, v2

    if-ge v1, v3, :cond_11

    .line 31
    aget-object v3, v2, v1

    invoke-virtual {v3}, Landroid/net/NetworkInfo;->isAvailable()Z

    move-result v3

    if-eqz v3, :cond_35

    .line 32
    sget-object v3, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->LOG_TAG:Ljava/lang/String;

    const-string v4, "network is available"

    invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 33
    const/4 v3, 0x1

    goto :goto_19

    .line 30
    :cond_35
    add-int/lit8 v1, v1, 0x1

    goto :goto_21
.end method

.method public static isNetworkRoaming(Landroid/content/Context;)Z
    .registers 6
    .param p0, "context"    # Landroid/content/Context;

    .prologue
    .line 46
    const-string v3, "connectivity"

    invoke-virtual {p0, v3}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/net/ConnectivityManager;

    .line 47
    .local v0, "connectivity":Landroid/net/ConnectivityManager;
    if-nez v0, :cond_13

    .line 48
    sget-object v3, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->LOG_TAG:Ljava/lang/String;

    const-string v4, "couldn\'t get connectivity manager"

    invoke-static {v3, v4}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 63
    :goto_11
    const/4 v3, 0x0

    :goto_12
    return v3

    .line 50
    :cond_13
    invoke-virtual {v0}, Landroid/net/ConnectivityManager;->getActiveNetworkInfo()Landroid/net/NetworkInfo;

    move-result-object v1

    .line 51
    .local v1, "info":Landroid/net/NetworkInfo;
    if-eqz v1, :cond_40

    invoke-virtual {v1}, Landroid/net/NetworkInfo;->getType()I

    move-result v3

    if-nez v3, :cond_40

    .line 52
    const-string v3, "phone"

    invoke-virtual {p0, v3}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/telephony/TelephonyManager;

    .line 53
    .local v2, "tm":Landroid/telephony/TelephonyManager;
    if-eqz v2, :cond_38

    invoke-virtual {v2}, Landroid/telephony/TelephonyManager;->isNetworkRoaming()Z

    move-result v3

    if-eqz v3, :cond_38

    .line 54
    sget-object v3, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->LOG_TAG:Ljava/lang/String;

    const-string v4, "network is roaming"

    invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 55
    const/4 v3, 0x1

    goto :goto_12

    .line 57
    :cond_38
    sget-object v3, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->LOG_TAG:Ljava/lang/String;

    const-string v4, "network is not roaming"

    invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_11

    .line 60
    .end local v2    # "tm":Landroid/telephony/TelephonyManager;
    :cond_40
    sget-object v3, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->LOG_TAG:Ljava/lang/String;

    const-string v4, "not using mobile network"

    invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_11
.end method

.method public static isWifiDataEnable(Landroid/content/Context;)Z
    .registers 5
    .param p0, "context"    # Landroid/content/Context;

    .prologue
    .line 90
    const/4 v2, 0x0

    .line 92
    .local v2, "isWifiDataEnable":Z
    :try_start_1
    const-string v3, "connectivity"

    invoke-virtual {p0, v3}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/net/ConnectivityManager;

    .line 93
    .local v0, "connectivityManager":Landroid/net/ConnectivityManager;
    const/4 v3, 0x1

    invoke-virtual {v0, v3}, Landroid/net/ConnectivityManager;->getNetworkInfo(I)Landroid/net/NetworkInfo;

    move-result-object v3

    invoke-virtual {v3}, Landroid/net/NetworkInfo;->isConnectedOrConnecting()Z
    :try_end_11
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_11} :catch_13

    move-result v2

    .line 98
    .end local v0    # "connectivityManager":Landroid/net/ConnectivityManager;
    :goto_12
    return v2

    .line 94
    :catch_13
    move-exception v1

    .line 95
    .local v1, "e":Ljava/lang/Exception;
    const/4 v2, 0x0

    goto :goto_12
.end method

.method public static setMobileDataEnabled(Landroid/content/Context;Z)V
    .registers 14
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "enabled"    # Z
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    const/4 v11, 0x1

    const/4 v10, 0x0

    .line 109
    invoke-static {p0}, Lcom/zuiapps/suite/utils/network/APNManager;->getInstance(Landroid/content/Context;)Lcom/zuiapps/suite/utils/network/APNManager;

    move-result-object v1

    .line 110
    .local v1, "apnManager":Lcom/zuiapps/suite/utils/network/APNManager;
    invoke-virtual {v1}, Lcom/zuiapps/suite/utils/network/APNManager;->getAPNList()Ljava/util/List;

    move-result-object v3

    .line 111
    .local v3, "list":Ljava/util/List;, "Ljava/util/List<Lcom/zuiapps/suite/utils/network/APN;>;"
    if-eqz p1, :cond_49

    .line 112
    invoke-interface {v3}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v4

    :goto_10
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v5

    if-eqz v5, :cond_ac

    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/zuiapps/suite/utils/network/APN;

    .line 113
    .local v0, "apn":Lcom/zuiapps/suite/utils/network/APN;
    new-instance v2, Landroid/content/ContentValues;

    invoke-direct {v2}, Landroid/content/ContentValues;-><init>()V

    .line 114
    .local v2, "cv":Landroid/content/ContentValues;
    const-string v5, "apn"

    iget-object v6, v0, Lcom/zuiapps/suite/utils/network/APN;->apn:Ljava/lang/String;

    invoke-virtual {v1, v6}, Lcom/zuiapps/suite/utils/network/APNManager;->matchAPN(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v2, v5, v6}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 115
    const-string v5, "type"

    iget-object v6, v0, Lcom/zuiapps/suite/utils/network/APN;->type:Ljava/lang/String;

    invoke-virtual {v1, v6}, Lcom/zuiapps/suite/utils/network/APNManager;->matchAPN(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v2, v5, v6}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 116
    invoke-virtual {p0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v5

    sget-object v6, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->uri:Landroid/net/Uri;

    const-string v7, "_id=?"

    new-array v8, v11, [Ljava/lang/String;

    iget-object v9, v0, Lcom/zuiapps/suite/utils/network/APN;->apnId:Ljava/lang/String;

    aput-object v9, v8, v10

    invoke-virtual {v5, v6, v2, v7, v8}, Landroid/content/ContentResolver;->update(Landroid/net/Uri;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    goto :goto_10

    .line 119
    .end local v0    # "apn":Lcom/zuiapps/suite/utils/network/APN;
    .end local v2    # "cv":Landroid/content/ContentValues;
    :cond_49
    invoke-interface {v3}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v4

    :goto_4d
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v5

    if-eqz v5, :cond_ac

    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/zuiapps/suite/utils/network/APN;

    .line 120
    .restart local v0    # "apn":Lcom/zuiapps/suite/utils/network/APN;
    new-instance v2, Landroid/content/ContentValues;

    invoke-direct {v2}, Landroid/content/ContentValues;-><init>()V

    .line 121
    .restart local v2    # "cv":Landroid/content/ContentValues;
    const-string v5, "apn"

    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V

    iget-object v7, v0, Lcom/zuiapps/suite/utils/network/APN;->apn:Ljava/lang/String;

    invoke-virtual {v1, v7}, Lcom/zuiapps/suite/utils/network/APNManager;->matchAPN(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    const-string v7, "mdev"

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v2, v5, v6}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 122
    const-string v5, "type"

    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V

    iget-object v7, v0, Lcom/zuiapps/suite/utils/network/APN;->type:Ljava/lang/String;

    invoke-virtual {v1, v7}, Lcom/zuiapps/suite/utils/network/APNManager;->matchAPN(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    const-string v7, "mdev"

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v2, v5, v6}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V

    .line 123
    invoke-virtual {p0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v5

    sget-object v6, Lcom/zuiapps/suite/utils/network/NetWorkHelper;->uri:Landroid/net/Uri;

    const-string v7, "_id=?"

    new-array v8, v11, [Ljava/lang/String;

    iget-object v9, v0, Lcom/zuiapps/suite/utils/network/APN;->apnId:Ljava/lang/String;

    aput-object v9, v8, v10

    invoke-virtual {v5, v6, v2, v7, v8}, Landroid/content/ContentResolver;->update(Landroid/net/Uri;Landroid/content/ContentValues;Ljava/lang/String;[Ljava/lang/String;)I

    goto :goto_4d

    .line 126
    .end local v0    # "apn":Lcom/zuiapps/suite/utils/network/APN;
    .end local v2    # "cv":Landroid/content/ContentValues;
    :cond_ac
    return-void
.end method
